package org.sippr.controller;

import org.sippr.pojo.Creation;
import org.sippr.pojo.Result;
import org.sippr.service.CreationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/creation")
public class CreationController {
    @Autowired
    private CreationService creationService;

    @PostMapping("/add")
    public Result add(@RequestBody @Validated Creation value) {
        creationService.add(value);
        return Result.success();
    }


    @GetMapping("/history")
    public Result history(Integer projectId) {
        List<Creation> creationList = creationService.findByProjectId(projectId);
        return Result.success(creationList);

    }

}
